/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Business;

import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author anhvtn_b00545
 */
public class loadBill extends AbstractTableModel{
    private int COLUMNS = 4;
    private List<Bill_BS> list;

     public loadBill(List<Bill_BS> list) {
        this.list = list;
    }
    public int getRowCount() {
        return list.size();
    }

    public int getColumnCount() {
        return COLUMNS;
    }

 @Override
    public String getColumnName(int column) {
        switch(column) {
            case 0 : return "Order Code";
            case 1 : return "Customer Name";
            case 2 : return "Delivery Date";
            case 3 : return "Status";

        }
        return null;
    }
    public Object getValueAt(int rowIndex, int columnIndex) {
        Bill_BS b = list.get(rowIndex);
        switch(columnIndex) {
            case 0 : return b.getBID();
            case 1 : return b.getCName();
            case 2 : return b.getBDeliveryDate();
            case 3 : 
                if(b.getBStatus() == 0)
                {
                    return "Unpaid";
                }
                else if(b.getBStatus() ==1)
                {
                    return "Part Payment";
                }
                else
                {
                    return "Paid";
                }
        }
        return null;
    }
    public void addOrder(List<Bill_BS> ls)    {
        list = ls;
        this.fireTableDataChanged();
    }

    public Bill_BS getOrderBS(int index) {
        return list.get(index);
    }
     public void deleteOrder(Bill_BS order) {
        list.remove(order);
        fireTableDataChanged();
    }
}
